﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Data;

namespace Smtp_server
{
    public partial class DBagent : Component
    {
        public DBagent()
        {
            InitializeComponent();
            // TODO: This line of code loads data into the 'dBSmtpDataSet1.Email' table. You can move, or remove it, as needed.
       
            this.emailTableAdapter.FillBy(this.dbSmtpDataSet1.Email);
        }

        public DBagent(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
            // TODO: This line of code loads data into the 'dBSmtpDataSet1.Email' table. You can move, or remove it, as needed.
            this.emailTableAdapter.Fill(this.dbSmtpDataSet1.Email);
            
        }

        public void Add(Email email)
        {
            // Create the right row
            DataRow dr = dbSmtpDataSet1.Email.NewEmailRow();
            dr["To"] = email.To;
            dr["From"] = email.From;
            dr["Cc"] = email.Cc;
            dr["Subject"] = email.Subject;
            dr["BodyText"] = email.BodyText;
            dr["Received"] = email.Received;
            // Add the row to the Email table
            dbSmtpDataSet1.Email.Rows.Add(dr);
            // Save the new row to the database
            this.emailTableAdapter.Update(this.dbSmtpDataSet1.Email);
            
            
        }
        public void Clear()
        {
            dbSmtpDataSet1.Clear();
        }
        
    }
}
